#include <cstdio>
#include <queue>

using std::queue;


#define MAX_KNIGHT_MOVEMENTS 8
#define MAX_R 8
#define MAX_C 8


struct Square
{
	int r, c;

	inline void operator += (const Square &s) {
		r += s.r;
		c += s.c;
	}

	inline bool operator == (const Square &s) const {
		return r == s.r && c == s.c;
	}

	inline bool operator != (const Square &s) const {
		return r != s.r || c != s.c;
	}

	inline void set (const char s[2]) {
		c = s[0] - 'a';
		r = s[1] - '1';
	}

	inline void set_sum (const Square &s1, const Square &s2) {
		*this = s1;
		*this += s2;
	}

	inline bool invalid () {
		return r < 0 || r >= MAX_R || c < 0 || c >= MAX_C;
	}
};


Square despl[MAX_KNIGHT_MOVEMENTS] = {
	{+2, +1}, {+2, -1},
	{-2, +1}, {-2, -1},
	{+1, +2}, {+1, -2},
	{-1, +2}, {-1, -2}
};


struct MovementsCount
{
	Square s;
	int c;
};


int min_movements (const char sa[2], const char sb[2])
{
	queue <MovementsCount> q;
	MovementsCount m, m_next;
	Square a, b;
	bool board[MAX_C][MAX_R] = {0};

	a.set (sa);
	b.set (sb);
	m.s = a;
	m.c = 0;

	while (m.s != b)
	{
		m_next.c = m.c + 1;
		for (int i = 0; i < MAX_KNIGHT_MOVEMENTS; ++i)
		{
			m_next.s.set_sum (m.s, despl[i]);
			bool &b = board[m_next.s.c][m_next.s.r];
			if (m_next.s.invalid () || b)
				continue;
			b = true;
			q.push (m_next);
		}
		m = q.front ();
		q.pop ();
	}

	return m.c;
}


int main ()
{
	char a[3], b[3];
	int m;

	a[2] = b[2] = '\0';

	while (scanf ("%2c %2c ", &a, &b) == 2)
	{
		m = min_movements (a, b);
		printf("To get from %s to %s takes %d knight moves.\n", a, b, m);
	}

	return 0;
}